﻿namespace HRM.CORE
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using Microsoft.VisualBasic;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using Dictionary.ERP;

    public class xfmShiftCheckOption : XtraForm
    {
        private SimpleButton btCancel;
        private SimpleButton btCreate;
        private CalcEdit calFromRow;
        private CalcEdit calToRow;
        private CheckEdit cheAll;
        private CheckEdit cheIsFilterByShift;
        private CheckEdit cheIsNotHoliday;
        private CheckEdit cheIsNotSaturday;
        private CheckEdit cheIsNotSunday;
        private CheckedListBoxControl clbShift;
        private IContainer components;
        private GroupBox groupBox1;
        private GroupBox groupBox2;
        private GroupControl groupControl1;
        public DevExpress.Utils.ImageCollection imageCollection2;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private LabelControl labelControl4;
        private LabelControl labelControl5;
        private LabelControl lcDescription;
        private int m_Month;
        private int m_Year;
        private RadioGroup rdOption;
        private TimeEdit teFromDate;
        private TimeEdit teToDate;

        public event UnShiftDataHandler UnShiftData;

        public xfmShiftCheckOption()
        {
            this.components = null;
            this.m_Month = 0;
            this.m_Year = 0;
            this.InitializeComponent();
            this.InitData();
        }

        public xfmShiftCheckOption(int Month, int Year)
        {
            this.components = null;
            this.m_Month = 0;
            this.m_Year = 0;
            this.InitializeComponent();
            this.m_Month = Month;
            this.m_Year = Year;
            this.InitData();
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btCreate_Click(object sender, EventArgs e)
        {
            if ((int.Parse(this.calFromRow.Text) < 1) || (int.Parse(this.calToRow.Text) < 1))
            {
                XtraMessageBox.Show("Số d\x00f2ng kh\x00f4ng được nhỏ hơn 1!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else if (int.Parse(this.calFromRow.Text) > int.Parse(this.calToRow.Text))
            {
                XtraMessageBox.Show("Số d\x00f2ng đến kh\x00f4ng được nhỏ hơn số d\x00f2ng đi!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else if (int.Parse(this.teFromDate.Text) > int.Parse(this.teToDate.Text))
            {
                XtraMessageBox.Show("Ng\x00e0y bắt đầu kh\x00f4ng được nhỏ hơn ng\x00e0y kết th\x00fac!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            else
            {
                bool isCheck = true;
                if (this.rdOption.SelectedIndex == 0)
                {
                    isCheck = true;
                }
                else
                {
                    isCheck = false;
                }
                DataTable shiftTable = new DataTable();
                DataColumn column = new DataColumn("ShiftCode");
                shiftTable.Columns.Add(column);
                foreach (CheckedListBoxItem item in this.clbShift.Items)
                {
                    if (item.CheckState == CheckState.Checked)
                    {
                        shiftTable.Rows.Add(new object[] { item.Value.ToString() });
                    }
                }
                this.RaiseUnShiftDataHandler(isCheck, int.Parse(this.teFromDate.Text), int.Parse(this.teToDate.Text), int.Parse(this.calFromRow.Text), int.Parse(this.calToRow.Text), this.cheAll.Checked, this.cheIsFilterByShift.Checked, shiftTable, this.cheIsNotSaturday.Checked, this.cheIsNotSunday.Checked, this.cheIsNotHoliday.Checked);
                base.Close();
            }
        }

        private void cheAll_CheckedChanged(object sender, EventArgs e)
        {
            if (this.cheAll.Checked)
            {
                this.calFromRow.Enabled = false;
                this.calToRow.Enabled = false;
            }
            else
            {
                this.calFromRow.Enabled = true;
                this.calToRow.Enabled = true;
            }
        }

        private void cheIsFilterByShift_CheckedChanged(object sender, EventArgs e)
        {
            if (this.cheIsFilterByShift.Checked)
            {
                this.clbShift.Enabled = true;
            }
            else
            {
                this.clbShift.Enabled = false;
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitData()
        {
            DateTime dateValue = new DateTime(this.m_Year, this.m_Month, 1);
            this.teFromDate.EditValue = dateValue;
            this.teToDate.EditValue = DateAndTime.DateAdd(DateInterval.Day, -1.0, DateAndTime.DateAdd(DateInterval.Month, 1.0, dateValue));
            this.calFromRow.EditValue = 1;
            this.calToRow.EditValue = 1;
            this.clbShift.Items.Clear();
            new DIC_SHIFT().AddCheckedListBox(this.clbShift);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xfmShiftCheckOption));
            this.btCreate = new SimpleButton();
            this.btCancel = new SimpleButton();
            this.lcDescription = new LabelControl();
            this.teFromDate = new TimeEdit();
            this.teToDate = new TimeEdit();
            this.calFromRow = new CalcEdit();
            this.calToRow = new CalcEdit();
            this.labelControl2 = new LabelControl();
            this.labelControl3 = new LabelControl();
            this.labelControl4 = new LabelControl();
            this.labelControl5 = new LabelControl();
            this.groupBox1 = new GroupBox();
            this.cheIsNotHoliday = new CheckEdit();
            this.cheIsNotSunday = new CheckEdit();
            this.cheIsNotSaturday = new CheckEdit();
            this.groupBox2 = new GroupBox();
            this.clbShift = new CheckedListBoxControl();
            this.cheIsFilterByShift = new CheckEdit();
            this.cheAll = new CheckEdit();
            this.rdOption = new RadioGroup();
            this.groupControl1 = new GroupControl();
            this.imageCollection2 = new DevExpress.Utils.ImageCollection(this.components);
            this.teFromDate.Properties.BeginInit();
            this.teToDate.Properties.BeginInit();
            this.calFromRow.Properties.BeginInit();
            this.calToRow.Properties.BeginInit();
            this.cheIsNotHoliday.Properties.BeginInit();
            this.cheIsNotSunday.Properties.BeginInit();
            this.cheIsNotSaturday.Properties.BeginInit();
            ((ISupportInitialize) this.clbShift).BeginInit();
            this.cheIsFilterByShift.Properties.BeginInit();
            this.cheAll.Properties.BeginInit();
            this.rdOption.Properties.BeginInit();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.imageCollection2.BeginInit();
            base.SuspendLayout();
            this.btCreate.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btCreate.ImageIndex = 0x27;
            this.btCreate.ImageList = this.imageCollection2;
            this.btCreate.Location = new Point(0x13d, 0x14b);
            this.btCreate.Name = "btCreate";
            this.btCreate.Size = new Size(0x6a, 0x17);
            this.btCreate.TabIndex = 2;
            this.btCreate.Text = "Đ\x00e1nh Dấu (>>)";
            this.btCreate.Click += new EventHandler(this.btCreate_Click);
            this.btCancel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btCancel.ImageIndex = 0x16;
            this.btCancel.ImageList = this.imageCollection2;
            this.btCancel.Location = new Point(0x1b7, 0x14b);
            this.btCancel.Name = "btCancel";
            this.btCancel.Size = new Size(0x62, 0x17);
            this.btCancel.TabIndex = 3;
            this.btCancel.Text = "Tho\x00e1t";
            this.btCancel.Click += new EventHandler(this.btCancel_Click);
            this.lcDescription.AllowHtmlString = true;
            this.lcDescription.Appearance.Options.UseTextOptions = true;
            this.lcDescription.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.lcDescription.AutoSizeMode = LabelAutoSizeMode.None;
            this.lcDescription.Location = new Point(0x10, 0x19);
            this.lcDescription.Name = "lcDescription";
            this.lcDescription.Size = new Size(520, 0x2d);
            this.lcDescription.TabIndex = 4;
            this.lcDescription.Text = "Chọn l\x00e0 [Chọn] hoặc [Bỏ chọn] từ \x00f4 ph\x00eda b\x00ean dưới, sau đ\x00f3 chọn ph\x00e1t sinh từ ng\x00e0y n\x00e0o đến ng\x00e0y n\x00e0o v\x00e0 từ d\x00f2ng n\x00e0o đến d\x00f2ng n\x00e0o trong lưới danh s\x00e1ch.";
            this.teFromDate.EditValue = new DateTime(0x7dc, 7, 3, 0, 0, 0, 0);
            this.teFromDate.Location = new Point(0x4a, 0x94);
            this.teFromDate.Name = "teFromDate";
            this.teFromDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teFromDate.Properties.Mask.EditMask = "dd";
            this.teFromDate.Size = new Size(0x2e, 20);
            this.teFromDate.TabIndex = 11;
            this.teToDate.EditValue = new DateTime(0x7dc, 7, 3, 0, 0, 0, 0);
            this.teToDate.Location = new Point(0x4a, 0xb2);
            this.teToDate.Name = "teToDate";
            this.teToDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teToDate.Properties.Mask.EditMask = "dd";
            this.teToDate.Size = new Size(0x2e, 20);
            this.teToDate.TabIndex = 12;
            int[] bits = new int[4];
            this.calFromRow.EditValue = new decimal(bits);
            this.calFromRow.Enabled = false;
            this.calFromRow.Location = new Point(0xec, 0xac);
            this.calFromRow.Name = "calFromRow";
            this.calFromRow.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calFromRow.Size = new Size(0x2b, 20);
            this.calFromRow.TabIndex = 13;
            bits = new int[4];
            this.calToRow.EditValue = new decimal(bits);
            this.calToRow.Enabled = false;
            this.calToRow.Location = new Point(0xec, 200);
            this.calToRow.Name = "calToRow";
            this.calToRow.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calToRow.Size = new Size(0x2b, 20);
            this.calToRow.TabIndex = 14;
            this.labelControl2.Location = new Point(0x11, 150);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x2c, 13);
            this.labelControl2.TabIndex = 15;
            this.labelControl2.Text = "Từ ng\x00e0y:";
            this.labelControl3.Location = new Point(0x10, 0xb5);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x33, 13);
            this.labelControl3.TabIndex = 0x10;
            this.labelControl3.Text = "Đến ng\x00e0y:";
            this.labelControl4.Location = new Point(0xb3, 0xcb);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x33, 13);
            this.labelControl4.TabIndex = 0x12;
            this.labelControl4.Text = "Đến d\x00f2ng:";
            this.labelControl5.Location = new Point(0xb3, 0xaf);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(0x2c, 13);
            this.labelControl5.TabIndex = 0x11;
            this.labelControl5.Text = "Từ d\x00f2ng:";
            this.groupBox1.Location = new Point(0x10, 0x76);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x9b, 0x13);
            this.groupBox1.TabIndex = 0x13;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Chọn ng\x00e0y";
            this.cheIsNotHoliday.EditValue = true;
            this.cheIsNotHoliday.Location = new Point(14, 0x111);
            this.cheIsNotHoliday.Name = "cheIsNotHoliday";
            this.cheIsNotHoliday.Properties.Caption = "Bỏ qua ng\x00e0y lễ";
            this.cheIsNotHoliday.Size = new Size(0x87, 0x13);
            this.cheIsNotHoliday.TabIndex = 30;
            this.cheIsNotSunday.EditValue = true;
            this.cheIsNotSunday.Location = new Point(14, 0xf5);
            this.cheIsNotSunday.Name = "cheIsNotSunday";
            this.cheIsNotSunday.Properties.Caption = "Bỏ qua ng\x00e0y chủ nhật";
            this.cheIsNotSunday.Size = new Size(0x87, 0x13);
            this.cheIsNotSunday.TabIndex = 0x1d;
            this.cheIsNotSaturday.Location = new Point(14, 0xd9);
            this.cheIsNotSaturday.Name = "cheIsNotSaturday";
            this.cheIsNotSaturday.Properties.Caption = "Bỏ qua ng\x00e0y thứ 7";
            this.cheIsNotSaturday.Size = new Size(0x87, 0x13);
            this.cheIsNotSaturday.TabIndex = 0x1c;
            this.groupBox2.Location = new Point(0xb0, 0x76);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new Size(0x169, 0x13);
            this.groupBox2.TabIndex = 20;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Chọn d\x00f2ng";
            this.clbShift.CheckOnClick = true;
            this.clbShift.Enabled = false;
            this.clbShift.HighlightedItemStyle = HighlightStyle.Skinned;
            this.clbShift.HotTrackItems = true;
            this.clbShift.ItemHeight = 0x18;
            this.clbShift.Location = new Point(0x128, 0xa9);
            this.clbShift.Name = "clbShift";
            this.clbShift.Size = new Size(0xf1, 0x81);
            this.clbShift.TabIndex = 0x1b;
            this.cheIsFilterByShift.Location = new Point(0x128, 0x90);
            this.cheIsFilterByShift.Name = "cheIsFilterByShift";
            this.cheIsFilterByShift.Properties.Caption = "Lọc theo ca";
            this.cheIsFilterByShift.Size = new Size(0x62, 0x13);
            this.cheIsFilterByShift.TabIndex = 0x15;
            this.cheIsFilterByShift.CheckedChanged += new EventHandler(this.cheIsFilterByShift_CheckedChanged);
            this.cheAll.EditValue = true;
            this.cheAll.Location = new Point(0xb1, 0x8f);
            this.cheAll.Name = "cheAll";
            this.cheAll.Properties.Caption = "Tất cả c\x00e1c d\x00f2ng";
            this.cheAll.Size = new Size(0x66, 0x13);
            this.cheAll.TabIndex = 0x13;
            this.cheAll.CheckedChanged += new EventHandler(this.cheAll_CheckedChanged);
            this.rdOption.EditValue = "0";
            this.rdOption.Location = new Point(0x11, 0x47);
            this.rdOption.Name = "rdOption";
            this.rdOption.Properties.Appearance.BackColor = Color.White;
            this.rdOption.Properties.Appearance.Font = new Font("Tahoma", 8f);
            this.rdOption.Properties.Appearance.ForeColor = Color.Black;
            this.rdOption.Properties.Appearance.Options.UseBackColor = true;
            this.rdOption.Properties.Appearance.Options.UseFont = true;
            this.rdOption.Properties.Appearance.Options.UseForeColor = true;
            this.rdOption.Properties.Items.AddRange(new RadioGroupItem[] { new RadioGroupItem("0", "Chọn"), new RadioGroupItem("1", "Bỏ chọn") });
            this.rdOption.Size = new Size(0x209, 0x21);
            this.rdOption.TabIndex = 0x15;
            this.groupControl1.Controls.Add(this.cheIsNotHoliday);
            this.groupControl1.Controls.Add(this.clbShift);
            this.groupControl1.Controls.Add(this.teToDate);
            this.groupControl1.Controls.Add(this.lcDescription);
            this.groupControl1.Controls.Add(this.rdOption);
            this.groupControl1.Controls.Add(this.cheIsNotSunday);
            this.groupControl1.Controls.Add(this.cheIsFilterByShift);
            this.groupControl1.Controls.Add(this.labelControl3);
            this.groupControl1.Controls.Add(this.cheAll);
            this.groupControl1.Controls.Add(this.cheIsNotSaturday);
            this.groupControl1.Controls.Add(this.groupBox2);
            this.groupControl1.Controls.Add(this.teFromDate);
            this.groupControl1.Controls.Add(this.calToRow);
            this.groupControl1.Controls.Add(this.labelControl2);
            this.groupControl1.Controls.Add(this.groupBox1);
            this.groupControl1.Controls.Add(this.calFromRow);
            this.groupControl1.Controls.Add(this.labelControl4);
            this.groupControl1.Controls.Add(this.labelControl5);
            this.groupControl1.Dock = DockStyle.Top;
            this.groupControl1.Location = new Point(0, 0);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new Size(0x229, 0x13c);
            this.groupControl1.TabIndex = 0x1f;
            this.groupControl1.Text = "T\x00f9y Chọn N\x00e2ng Cao";
            this.imageCollection2.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection2.ImageStream");
            this.imageCollection2.Images.SetKeyName(0x3d, "Vista (35).ico");
            this.imageCollection2.Images.SetKeyName(0x3e, "Security.ico");
            this.imageCollection2.Images.SetKeyName(0x3f, "RibbonPrintPreview_DocumentMapLarge.png");
            this.imageCollection2.Images.SetKeyName(0x40, "11.png");
            this.imageCollection2.Images.SetKeyName(0x41, "Sua.png");
            this.imageCollection2.Images.SetKeyName(0x42, "Them.png");
            this.imageCollection2.Images.SetKeyName(0x43, "PhanQuyen.png");
            this.imageCollection2.Images.SetKeyName(0x44, "11.png");
            this.imageCollection2.Images.SetKeyName(0x45, "plus.png");
            this.imageCollection2.Images.SetKeyName(70, "send.png");
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x229, 0x16e);
            base.Controls.Add(this.groupControl1);
            base.Controls.Add(this.btCancel);
            base.Controls.Add(this.btCreate);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "xfmShiftCheckOption";
            base.ShowIcon = false;
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "Đ\x00e1nh Dấu Chọn Nhanh";
            this.teFromDate.Properties.EndInit();
            this.teToDate.Properties.EndInit();
            this.calFromRow.Properties.EndInit();
            this.calToRow.Properties.EndInit();
            this.cheIsNotHoliday.Properties.EndInit();
            this.cheIsNotSunday.Properties.EndInit();
            this.cheIsNotSaturday.Properties.EndInit();
            ((ISupportInitialize) this.clbShift).EndInit();
            this.cheIsFilterByShift.Properties.EndInit();
            this.cheAll.Properties.EndInit();
            this.rdOption.Properties.EndInit();
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.groupControl1.PerformLayout();
            this.imageCollection2.EndInit();
            base.ResumeLayout(false);
        }

        private void RaiseUnShiftDataHandler(bool IsCheck, int FromDate, int ToDate, int FromRow, int ToRow, bool IsCheckAll, bool IsFilterByShift, DataTable ShiftTable, bool IsNotSaturday, bool IsNotSunday, bool IsNotHoliday)
        {
            if (this.UnShiftData != null)
            {
                this.UnShiftData(this, IsCheck, FromDate, ToDate, FromRow, ToRow, IsCheckAll, IsFilterByShift, ShiftTable, IsNotSaturday, IsNotSunday, IsNotHoliday);
            }
        }

        public delegate void UnShiftDataHandler(object sender, bool IsCheck, int FromDate, int ToDate, int FromRow, int ToRow, bool IsCheckAll, bool IsFilterByShift, DataTable ShiftTable, bool IsNotSaturday, bool IsNotSunday, bool IsNotHoliday);
    }
}

